/**
 * 
 */
package com.itee.protocal.meta;

/**
 * @author eeeee
 * 
 */
public enum DenyError {
	TIME_OUT(0, "通信超时"), INVALID_DATA(1, "无效的数据单元"), LENGTH_ERROR(2, "长度错"), CHECK_ERROR(
			3, "校验错"), IMFO_NOEXIST(4, "信息类不存在"), FORMAT_ERROR(5, "格式错误"), CHECK_ERR(
			6, "表号重复"), NUM_NOEXIST(7, "表号不存在"), APP_NORESPONSE(8, "电表应用层无应答"), MAJORNODE_BUSY(
			9, "主节点忙"), MAJORNODE_NOSUPPORT(10, "主节点不支持此命令"), NODE_NORESPONSE(
			11, "从节点不应答"), NODE_NONET(12, "从节点不在网内");
	private String name;

	private byte code;

	private DenyError(int code, String name) {
		this.name = name;
		this.code = (byte) code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	public static DenyError parseCode(byte code) {
		DenyError[] errors = DenyError.values();
		for (DenyError denyError : errors) {
			if (denyError.getCode() == code) {
				return denyError;
			}
		}
		return null;
	}
}
